function Game(el){
    this.el = document.querySelector('.map')
    this.map = new Map(this.el)
    this.map.create()
    this.food = new Food(this.el)
    this.food.create()
    this.food.move()
    this.snake = new Snake(this.el)
    this.snake.create()
}
Game.prototype.start = function(){

    setInterval(()=>{
        this.snake.move()
        let snakex = this.snake.snakeObj[0].x*20
        let snakey = this.snake.snakeObj[0].y*20
        let foodx =  this.food.foodx
        let foody =  this.food.foody
        if(snakex==foodx && snakey==foody){
            let t = this.snake.snakeObj[this.snake.snakeObj.length-1]
            this.snake.snakeObj.push({
                x: t.x,
                y :t.y,
                color:t.color,
                el:null})
                this.snake.create()
                this.food.move()
        }
       
       
    },150)
    document.addEventListener('keydown',(evt)=>{
        e = evt || window.event
        switch(e.keyCode){
            case 38:
            this.snake.direction = 'top'
            break;
            case 40:
            this.snake.direction = 'bottom'
            break;
            case 37:
            this.snake.direction = 'left'
            break;
            case 39:
            this.snake.direction = 'right'
            break;
    
        }



    })
}